﻿if($.browser.msie){//IE
        document.body.oncopy = function(){
            setTimeout(
             function(){
                var text = clipboardData.getData("text");
                 if (text) {
                    text = text + "本篇文章来源于www.shbst.net 原文出处："+location.href; clipboardData.setData("text", text);
                 }
              }, 100 )
        }
}else{
   document.oncopy = addLink;
}
window.onload = function()
{
    this.focus();
}
function addLink() {
 
    var body_element = document.getElementsByTagName('body')[0];
    var selection;
    selection = window.getSelection();
    var pagelink = "<br />本篇文章来源于www.shbst.net 原文出处: <a href='"+document.location.href+"'>"+document.location.href+"</a>";
    var copytext = selection + pagelink;
    var newdiv = document.createElement('div');
    newdiv.style.position='absolute';
    newdiv.style.left='-99999px';
    body_element.appendChild(newdiv);
    newdiv.innerHTML = copytext;
    selection.selectAllChildren(newdiv);
    window.setTimeout(function() {
        body_element.removeChild(newdiv);
    },0);
 
 }